Skip to content

Tree-sitter highlighting engine#617

Merged
tomlin7 merged 19 commits intomainfrom
feat/tree-sitter
Feb 6, 2026
Merged

Tree-sitter highlighting engine#617
tomlin7 merged 19 commits intomainfrom
feat/tree-sitter

Conversation

@tomlin7
Copy link
Copy Markdown
Owner

@tomlin7 tomlin7 commented Feb 6, 2026

Changes

src/biscuit/editor/text/ts_highlighter.py — The Tree-sitter highlighting engine:

  • TreeSitterHighlighter class with full/incremental parsing
  • highlight() — Full parse for file load/language change
  • incremental_highlight(edit_info) — Uses tree.edit() + parser.parse(old_tree) + changed_ranges() to only re-highlight what changed
  • Language detection via extension map (78 extensions) and alias map (62 aliases)
  • Display names for 47 languages in the statusbar
  • Graceful fallback to plain text for unsupported languages

src/biscuit/editor/text/queries/<lang>/highlights.scm — Highlight queries for 25 languages:
bash, c, cpp, csharp, css, go, html, java, javascript, json, kotlin, lua, markdown, php, python, ruby, rust, scala, sql, swift, toml, tsx, typescript, yaml, zig

src/biscuit/editor/text/highlighter.py — Pygments completely commented out, replaced with thin wrapper delegating to TreeSitterHighlighter. Original Pygments implementation preserved as comments.

src/biscuit/editor/text/text.py — Wired incremental parsing:

  • _proxy() captures edit positions (byte offsets + row/col points) before/after each insert/delete/replace
  • refresh() uses incremental_highlight() when edit info is available, falls back to full highlight() otherwise
  • Refactored _proxy() to stay within complexity limit

src/biscuit/settings/theme/theme.py — Added treesitter_syntax dict mapping 55 Tree-sitter capture names (@keyword, @string, @function, etc.) to existing theme color variables. All 6 themes inherit automatically.

@dosubot
Copy link
Copy Markdown

dosubot bot commented Feb 6, 2026

Related Documentation

Checked 1 published document(s) in 1 knowledge base(s). No updates required.

How did I do? Any feedback?  Join Discord

@tomlin7 tomlin7 merged commit 03b68fc into main Feb 6, 2026
5 of 7 checks passed
@tomlin7 tomlin7 deleted the feat/tree-sitter branch February 6, 2026 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant